package com.wmeimob.fastboot.jiubei.controller;

import com.github.pagehelper.PageInfo;
import com.wmeimob.fastboot.core.context.PageContext;
import com.wmeimob.fastboot.jiubei.entity.ShopOrderItems;
import com.wmeimob.fastboot.jiubei.service.ShopOrderItemsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @className ShopOrderItemsController
 * @description 【订单明细】控制器
 * @author wjt
 * @date Mon Aug 31 23:57:11 CST 2020
 * @version 1.0
 **/
@RestController
@RequestMapping("shopOrderItems")
@Slf4j
public class ShopOrderItemsController {

    @Resource
    private ShopOrderItemsService shopOrderItemsService;




    /**
     * 订单明细分页查询
     * @param shopOrderItems
     * @return
     */
    @GetMapping
    public PageInfo queryForShopOrderItems(ShopOrderItems shopOrderItems){
        PageContext.startPage();
        return new PageInfo<ShopOrderItems>(shopOrderItemsService.list(shopOrderItems));
         
    }

     /**
     * 订单明细导出
     * @param shopOrderItems
     * @return
     */
    @PostMapping("/export")
    public List<ShopOrderItems> queryForShopOrderItemsExport(@RequestBody ShopOrderItems  shopOrderItems){
        return  shopOrderItemsService.list(shopOrderItems);
    }


    /**
     * 订单明细查询-<通过id查询>
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public ShopOrderItems queryForShopOrderItemsById(@PathVariable("id") Long id){
            return  shopOrderItemsService.queryShopOrderItemsById(id);
    }


    /**
     * 订单明细添加
     * @param shopOrderItems
     * @return
     */
    @PostMapping
    public void insertForShopOrderItems(@RequestBody ShopOrderItems shopOrderItems){
            shopOrderItemsService.addShopOrderItems(shopOrderItems);    
    }


    /**
     * 订单明细修改
     * @param shopOrderItems
     * @return
     */
    @PutMapping
    public void updateForShopOrderItems(@RequestBody ShopOrderItems shopOrderItems){
            shopOrderItemsService.modifyShopOrderItems(shopOrderItems);  
    }

    /**
     * 订单明细删除
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public void removeForShopOrderItems(@PathVariable("id") Long id){
            shopOrderItemsService.removeShopOrderItems(id);
    }
}
